/**********************************************************************************
// Sprite Header File
// 
// Creation:	11 Jul 2007
// Updated:		26 Apr 2011
// Compiler:	Visual Studio 2010
//
// Notes:		Defines a sprite engine
//
**********************************************************************************/

#ifndef _ANABELE_SPRITE_H_
#define _ANABELE_SPRITE_H_

// make classes and functions exportable to a DLL
#ifdef ANABELE_EXPORTS
#define DLL __declspec( dllexport )
#else
#define DLL __declspec( dllimport )
#endif

/**********************************************************************************/

#include "D3DGame.h"		// include D3DGame
#include "GameObject.h"     // a sprite is a game object
#include "Geometry.h"       // a sprite can have a bounding box
#include "Color.h"          // include Color definition
#include "Animation.h"      // an animation can be attached
#include "Types.h"			// use engine custom types

/**********************************************************************************/

class DLL Sprite: public GameObject
{
public:
	Animation * animation;      // attached animation
	Geometry * boundingbox;		// sprite bounding box
	float rotation;				// angle of rotation to be applied
	float scalingX;				// scaling factor of the X coodinate
	float scalingY;				// scaling factor of the Y coodinate

private:
	LPDIRECT3DTEXTURE9 texture;	// direct3d texture for sprite
	uint width;					// sprite width
	uint height;				// sprite height
	uint columns;				// number of columns in the sprite sheet

public:
	Sprite(char * filename, uint frameWidth = 0, 
		uint frameHeight = 0, uint numColumns = 1, 
		Color colorkey = Color(255,0,255));			// constructor
	~Sprite();										// destructor

	void Translate(float dx, float dy);				// move the sprite by delta				
	void MoveTo(float px, float py);				// move the sprite to coordinates
	void MoveTo(int px, int py);					// move the sprite to coordinates
	void Rotate(float angle);						// rotate the texture by the given angle
	void Scale(float xScale, float yScale);			// scale the texture by the given factors
	void Draw(int frame);							// draw the sprite onscreen
	void Draw();									// draw the sprite onscreen
	uint GetWidth();								// get image width
	uint GetHeight();								// get image height
}; 

/**********************************************************************************/
// InLine Member Functions

inline void Sprite::Draw()
{ Draw(0); }

inline uint Sprite::GetWidth()
{ return width; }

inline uint Sprite::GetHeight()
{ return height; }

/**********************************************************************************/


#endif